@import "content";
@import "variables";

.blocks {
    .block-group, .block-group-horizontal {
        .empty-info {
            background: #fff;
            color: $gray-600;
            border-color: $gray-400;
            margin: 0;
        }
    }

    >div >.block {
        margin-top: -1rem;
        margin-bottom: -1rem;
    }

    &.blocks-outline {
        .block {
            border-color: $gray-400;

            .block {
                border-color: transparent;
            }

            &.danger {
                border-color: $danger;
            }

            &.block-group:hover:not(.danger), &:focus-within {
                border-color: $gray-400;
            }
        }
    }
}

.block {
    position: relative;
    max-width: $block-width;
    margin: 0 auto;
    padding: 2.75rem 1rem;
    border: solid 1px transparent;
    border-radius: $border-radius;
    transition: border-color .2s ease-in-out;

    .block-header {
        color: $gray-500;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: .5rem 1rem;
        font-size: .8rem;
        opacity: 0;
        transition: opacity ease-in-out .2s;

        .title {
            float: left;
            margin-top: .25rem;

            i {
                font-size: .875rem;
                padding-right: .5rem;
            }

            strong {
                text-transform: uppercase;
            }
        }
    }

    &.collapsed {
        border-color: $gray-400;
        padding-bottom: 0;

        > .block-header {
            opacity: 1;
        }

        > .block-body, > .block-group {
            display: none;
        }
    }

    &.block-full {
        max-width: none;
    }

    .actions, .custom-actions {
        float: right;

        .btn {
            background: $gray-100;
            width: 1.75rem;
            height: 1.75rem;
            border-radius: 50%;
            position: relative;
            transition: all ease-in-out .2s;

            i {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translateX(-50%) translateY(-50%);
            }

            &:hover {
                background: $gray-400;
            }

            &.danger {
                color: $danger;

                &:hover {
                    background: $danger;
                    color: $white;
                }
            }

            &.add {
                color: $primary;

                &:hover {
                    background: $primary;
                    color: $white;
                }
            }

            &.selected {
                background: $gray-400 !important;
            }
        }

        .btn {
            cursor: pointer;
        }
    }

    .custom-actions {
        position: absolute;
        top: .5rem;
        right: 7rem;
        float: none;
        opacity: 0;
        transition: opacity ease-in-out .2s;
    }

    .has-media-picker {
        .media-picker {
            background: rgba(0,0,0,.4);
            position: absolute;
            width: 90%;
            top: 50%;
            left: 5%;
            padding: 1.5rem;
            margin-top: -2.5rem;
            opacity: 0;
            border-radius: $border-radius;
            transition: opacity ease-in-out .2s;

            &.slide-in {
                position: relative;
                width: 0;
                height: 35px;
                top: auto;
                left: auto;
                margin-top: 0;
                padding: 0;
                background-color: transparent;
                transition: all ease-in-out .2s;

                .card {
                    margin-left: 1rem;
                }

                .card-body {
                    border: 1px solid $gray-400;
                }
            }

            .card-body {
                padding: .4rem 1rem;
                margin-right: 1rem;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
        }
    }

    &:hover, &:focus-within {
        >.has-media-picker {
            .media-picker {
                opacity: 1;

                &.slide-in {
                    width: 50%;
                }
            }
        }
    }

    &:hover, &:focus-within {
        border-color: $gray-400;

        >.block-header, .custom-actions {
            opacity: 1;
        }
    }

    &.danger {
        border-color: $danger;
    }
}

.html-block, .html-column-block {
    @include content();

    .empty:not(:focus-within) {
        background: $gray-100 url("../img/empty-text.png") no-repeat 50% 50%;
        height: 8rem;
    }
}

.markdown-block {
    .markdown-field{
        border: none;

        .editor-toolbar:not(.fullscreen) {
            border: solid 1px $gray-400;
        }

        .CodeMirror:not(.CodeMirror-fullscreen) {
            padding-left: 0;
            min-height: 150px;
        }
        .CodeMirror-scroll:not(.CodeMirror-fullscreen) {
            min-height: 150px;
        }
    }
}

.text-block {
    .block-body {
        display: grid;

        textarea {
            color: $gray-900;
            width: 100%;
            height: 100%;
            min-height: 1.3rem;
            border: 0;
            background: transparent;
            font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
            font-size: .875rem;
            margin-bottom: 0;
            overflow: hidden;
            resize: none;
            grid-area: 1 / 1 / 2 / 2;

            &:focus, &:active {
                outline: none;
            }
        }

        pre {
            white-space: pre-wrap;
            grid-area: 1 / 1 / 2 / 2;
        }
    }
}

.quote-block {
    .blockquote {
        *[contenteditable] {
            cursor: text;
            padding: .5rem;
        }

        *[data-placeholder]:empty {
            &:after {
                content: attr(data-placeholder);
                color: $gray-500;
            }
        }

        .blockquote-body {
            font-family: "Open Sans", serif;
            font-size: 1.4rem;
            margin-bottom: 0;
            color: $gray-600;
        }
    }
}

.image-block {
    position: relative;
    text-align: center;

    .empty {
        background: $gray-100;
    }

    &.primary-image {
        &:not(.primary-image-modal) {
            padding: 1rem 0;
            margin-bottom: 2rem !important;
        }
        &.primary-image-modal {
            background: $white;
            padding: .5rem;
            margin-bottom: 0 !important;
            border: 1px solid $gray-400;

            &:hover {
                border: 1px solid $gray-400;
            }
        }

        &:hover, &:focus-within {
            border-color: transparent;
        }
    }

    .btn-aspect {
        img {
            width: 15px !important;
            height: 15px !important;
            float: left;
            border: solid 1px #fff;
            border-radius: .125rem;
        }
    }

    .aspect-menu {
        label {
            font-weight: bold;
            padding: .25rem 1.5rem;
            white-space: nowrap;
        }

        img {
            width: 18px !important;
            height: 18px !important;
            background: #666;
            margin-right: .5rem;
            border: solid 2px #666;
            border-radius: .25rem;
            float: left;
            margin-top: .125rem;
        }

        .active {
            img {
                background: #007eaa;
                border-color: #007eaa;
            }
        }
    }
}

.page-block, .post-block, .content-block {
    .page-image {
        float: left;
        background: $body-bg;
        background-position: 50% 50%;
        background-repeat: no-repeat;
        max-width: 446px;
        margin-bottom: 0;
        margin-right: 1rem;
        text-align: center;
        border-radius: $border-radius;
    }

    img {
        border-radius: $border-radius;
    }

    h3 {
        font-family: Bitter,serif;
    }

}

.block-group {
    .col:not(:only-child) {
        .page-block, .post-block, .content-block {
            .page-image {
                float: none;
                margin-bottom: .5rem;
                margin-right: 0;
            }
        }
    }
}

.separator-block {
    padding: .75rem 1rem;

    hr {
        width: 80%;
        border-color: $gray-400;
    }
}

.text-block {
    .empty:not(:focus-within) {
        background: $gray-100 url("../img/empty-text.png") no-repeat 50% 50%;
        height: 8rem;
    }

    pre {
        min-height: 1.3rem;
        height: 100%;
        font-size: .875rem;
        margin-bottom: 0;
        white-space: normal;
    }

    p {
        min-height: 1.3rem;
        height: 100%;
        padding: 0 1rem;
    }
}

.ingress {
    padding: 1rem 0;
    margin-bottom: 1rem !important;

    .component-toolbar {
        margin-top: -1.5rem;
    }

    &.ingress-text {
        font-family: "Open Sans", sans-serif;
        font-size: 1.2rem;
        font-weight: 300;

        &.empty:not(:focus-within) {
            p {
                height: 100%;
            }
        }
    }

    &.empty:not(:focus-within) {
        background: $gray-100 url("../img/empty-text.png") no-repeat 50% 50%;
        height: 8rem;

        .block-body {
            height: 100%;
        }
    }

    &:hover, &:focus-within {
        border-color: transparent;
    }
}

.missing-block {
    border: 0;
    padding: 0;

    .alert {
        margin: .5rem 0;
    }
}

.block-add {
    display: block;
    position: relative;
    height: 10px;
    width: 150px;
    padding: 1rem;
    margin: .125rem auto;
    transition: all ease-in-out .2s;

    hr {
        margin: 0;
        border-top-width: 2px;
        border-color: transparent;
        transition: border-color ease-in-out .2s;
    }

    i {
        background: $white;
        color: $gray-200;
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -18px;
        margin-left: -18px;
        font-size: 28px;
        border: solid 4px $white;
        border-radius: 50%;
        z-index: 1000;
        transition: color ease-in-out .2s;
    }
}

a.block-add {
    &:hover, &:focus-within, &.active {
        width: 100%;
        max-width: 960px;
        outline: 0;

        hr {
            border-color: $gray-700;
        }

        i {
            color: $gray-700;
        }
    }
}

.content-blocker {
    background: #fff;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    z-index: 100;
    display: none;
}

.readonly {
    .content-blocker {
        display: block;
    }

    &.region {
        .content-blocker {
            z-index: 1100;
        }
    }
}

.bg-light {
    .block-add {
        i {
            background: $gray-100;
            border-color: $gray-100;
            color: $primary;
        }

        &:hover, &:focus-within, &.active {
            i {
                color: $gray-700;
            }
        }
    }
}